﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Objects.aspx.cs" Inherits="PmSadis.WebFormsUi.Operator.Objects" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridLookup" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%--<asp:Content ID="objectsHead" ContentPlaceHolderID="head" runat="server">
</asp:Content>--%>
<asp:Content ID="objectsContent" ContentPlaceHolderID="content" runat="server">
    <link href="../Content/oper.objects.css" rel="stylesheet" type="text/css" />
    <h2>Объекты содержания</h2>
    <asp:ScriptManager ID="objectsScriptManager" runat="server" />
    <!--objects data source-->
    <asp:ObjectDataSource ID="dsObjects" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Objects"
        SelectMethod="GetAll" UpdateMethod="UpdateObject" InsertMethod="InsertObject"
        DeleteMethod="DeleteObject" />
    <!--object types data source-->
    <asp:ObjectDataSource ID="dsObjectTypes" runat="server" TypeName="PmSadis.Providers.AppEnums"
        SelectMethod="GetAllObjectTypes" />
    <!--element types data source-->
    <asp:ObjectDataSource ID="dsElementTypes" runat="server" TypeName="PmSadis.Providers.AppEnums"
        SelectMethod="GetAllElementTypes" />
    <!--object elements data source-->
    <asp:ObjectDataSource ID="dsObjectElements" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Objects" SelectMethod="ObjectElements" UpdateMethod="UpdateObjectElement" InsertMethod="InsertObjectElement" DeleteMethod="DeleteObjectElement">
        <SelectParameters>
            <asp:SessionParameter Name="objectId" DbType="Int32" SessionField="oper-expanded-object-id" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <!--elements data source-->
    <asp:ObjectDataSource ID="dsElements" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Objects" SelectMethod="Elements">
        <SelectParameters>
            <asp:SessionParameter Name="objectType" DbType="Int32" SessionField="oper-expanded-object-type" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <!--units data source-->
    <asp:ObjectDataSource ID="dsUnits" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Objects" SelectMethod="Units" />
    <asp:UpdatePanel ID="objectsUpdatePanel" runat="server">
        <ContentTemplate>
            <dx:ASPxGridView ID="gvObjects" runat="server" DataSourceID="dsObjects" KeyFieldName="ObjectId" OnInit="gvObjects_Init"
                OnRowUpdating="gvObjects_RowUpdating">
                <SettingsDetail ShowDetailButtons="true" ShowDetailRow="true" />
                <Columns>
                    <dx:GridViewDataColumn FieldName="ObjectId" Visible="false" />
                    <dx:GridViewDataDateColumn FieldName="DateCreate" Visible="false" />
                    <dx:GridViewCommandColumn>
                        <NewButton Visible="true" />
                        <EditButton Visible="true" />
                        <DeleteButton Visible="true" />
                    </dx:GridViewCommandColumn>
                    <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование" />
                    <dx:GridViewDataTextColumn FieldName="Code" Caption="Код" />
                    <dx:GridViewDataComboBoxColumn FieldName="ObjectType" Caption="Тип">
                        <PropertiesComboBox DataSourceID="dsObjectTypes" />
                    </dx:GridViewDataComboBoxColumn>
                </Columns>
                <Templates>
                    <DetailRow>
                        <h3>Элементы объекта содержания <%#Eval("Code") %></h3>
                        <h4><%#Eval("Name") %></h4>
                        <dx:ASPxGridView ID="gvObjectElements" runat="server" DataSourceID="dsObjectElements" KeyFieldName="ObjectElementId" OnInit="gvObjectElements_Init" OnBeforePerformDataSelect="gvObjectElements_BeforePerformDataSelect" OnRowUpdating="gvObjectElements_RowUpdating" OnRowInserting="gvObjectElements_RowInserting" >
                            <Columns>
                                <dx:GridViewDataColumn FieldName="ObjectElementId" Visible="false" />
                                <dx:GridViewDataDateColumn FieldName="DateCreate" Visible="false" />
                                <dx:GridViewDataDateColumn FieldName="ObjectId" Visible="false" />
                                <dx:GridViewCommandColumn>
                                    <NewButton Visible="true" />
                                    <EditButton Visible="true" />
                                    <DeleteButton Visible="true" />
                                </dx:GridViewCommandColumn>
                                 <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование элемента" >
                                   <EditFormSettings Visible="False" />
                               </dx:GridViewDataTextColumn>
                                <dx:GridViewDataSpinEditColumn FieldName="BegKm" Caption="Начало, км" />
                                <dx:GridViewDataSpinEditColumn FieldName="EndKm" Caption="Конец, км" />
                                <dx:GridViewDataTextColumn FieldName="Location" Caption="Расположение" />
                                <dx:GridViewDataComboBoxColumn FieldName="UnitId" Caption="Ед. изм.">
                                    <PropertiesComboBox DataSourceID="dsUnits" ValueField="UnitId" ValueType="System.Int32" TextField="Name" />
                                    <EditFormSettings Visible="False" />
                                </dx:GridViewDataComboBoxColumn>
                                <dx:GridViewDataSpinEditColumn FieldName="Value" Caption="Объем, ед. изм." />
                                <dx:GridViewDataComboBoxColumn FieldName="ElementId" Visible="false" Caption="Элемент">
                                    <EditFormSettings Visible="True" />
                                    <EditItemTemplate>
                                        <dx:ASPxGridLookup ID="lucElements" runat="server" DataSourceID="dsElements" KeyFieldName="ElementId" Width="100%" SelectionMode="Single" OnInit="lucElements_Init">
                                            <GridViewProperties> 
                                                <Settings ShowFilterRow="true" ShowFilterRowMenu="true" />
                                            </GridViewProperties>
                                            <Columns>
                                                <dx:GridViewCommandColumn Caption="Выбрать" ShowSelectCheckbox="true">
                                                </dx:GridViewCommandColumn>
                                                <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование элемента" />
                                                <dx:GridViewDataTextColumn FieldName="UnitName" Caption="Единица измерения" />
                                                <dx:GridViewDataComboBoxColumn FieldName="ElementType" Caption="Тип элемента">
                                                    <PropertiesComboBox DataSourceID="dsElementTypes" />
                                                </dx:GridViewDataComboBoxColumn>
                                            </Columns>
                                        </dx:ASPxGridLookup>
                                    </EditItemTemplate>
                                </dx:GridViewDataComboBoxColumn>
                            </Columns>
                        </dx:ASPxGridView>
                    </DetailRow>
                </Templates>
            </dx:ASPxGridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
